const express=require('express')
const bodyParse=require('body-parser')
var fileupload = require("express-fileupload");

const app=express()
//设置允许跨域访问该服务.
app.all('*', function (req, res, next) {
  res.header('Access-Control-Allow-Origin', '*');
  //Access-Control-Allow-Headers ,可根据浏览器的F12查看,把对应的粘贴在这里就行
  res.header('Access-Control-Allow-Headers', '*');
  res.header('Access-Control-Allow-Methods', '*');
  res.header('Content-Type', 'application/json;charset=utf-8');
  next();
});


const userRouter=require('./user')
const kindRouter=require('./kind')
const productRouter=require('./product')

app.use(bodyParse.json())
app.use(fileupload());
app.use('/user',userRouter)
app.use('/kind',kindRouter)
app.use('/product',productRouter)
const server=require('http').Server(app)


server.listen(9092,function () {
  console.log('Node app start at port 9092');
})








